package packWindow;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.TextArea;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.Panel;

import javax.swing.ButtonGroup;
import javax.swing.ButtonModel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JTextPane;
import javax.swing.JComboBox;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class Aaaaa extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private ButtonGroup taldea;
	private JRadioButton rdbtnEmakumea;
	private JRadioButton rdbtnGizona;
	private JButton btnDatuakBidali;
	private JRadioButton rdbtmEmakumea;
	private JRadioButton rdbtmGizona;
	private TextArea textArea;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Aaaaa frame = new Aaaaa();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Aaaaa() {
		setTitle("tituloa");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 297);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblIzena = new JLabel("Izena:");
		lblIzena.setBounds(24, 12, 70, 15);
		contentPane.add(lblIzena);
		
		textField = new JTextField();
		textField.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				Color kolorea = new Color (255, 255, 255);
				
				textField.setBackground(kolorea);
				textArea
			}
		});
		textField.setBounds(108, 10, 300, 19);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JLabel lblSexua = new JLabel("Sexua:");
		lblSexua.setBounds(24, 59, 70, 15);
		contentPane.add(lblSexua);
		
		JLabel lblJaiotzeUrtea = new JLabel("Jaiotze urtea:");
		lblJaiotzeUrtea.setBounds(24, 104, 122, 15);
		contentPane.add(lblJaiotzeUrtea);
		
		rdbtnEmakumea = new JRadioButton("Emakumea");
		rdbtnEmakumea.setBounds(103, 55, 149, 19);
		contentPane.add(rdbtnEmakumea);
		
		rdbtnGizona = new JRadioButton("Gizona");
		rdbtnGizona.setBounds(103, 78, 149, 23);
		contentPane.add(rdbtnGizona);
		
		taldea = new ButtonGroup();
		taldea.add(rdbtnEmakumea);
		taldea.add(rdbtnGizona);
		
		JTextPane textPane = new JTextPane();
		textPane.setBounds(24, 141, 392, 93);
		contentPane.add(textPane);
		
		
		final JComboBox comboBox = new JComboBox();
		comboBox.setBounds(133, 104, 84, 23);
		contentPane.add(comboBox);
		
		for (int i=1900; i<2012; i++)
		comboBox.addItem(i);
		
		btnDatuakBidali = new JButton("Datuak Bidali");
		btnDatuakBidali.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				System.out.println("Botoia sakatu dut");
				if(!textField.getText().equals("")) {
				String izena = textField.getText();
				Integer urtea = (Integer) comboBox.getSelectedItem();
				
				ButtonModel bm = taldea.getSelection();
				
				String sexua = "";
				
				if (bm ==rdbtnEmakumea.getModel())
					sexua = rdbtmEmakumea.getText();
				else
					sexua = rdbtmGizona.getText();
				
				textArea.setText("Izena: " + izena + " \nSexua: " + sexua + "\nUrtea: " + urtea);
			}}
			textArea.setText("SartuIzena");
			textField.setBackground(Color.red);
			
		});

		btnDatuakBidali.setBounds(267, 99, 141, 25);
		contentPane.add(btnDatuakBidali);
	}
}
